<?php
function csv_to_array($filename='', $delimiter=',')
{
    if(!file_exists($filename) || !is_readable($filename))
	{
	   return FALSE;
	}
    $header = NULL;
    $data = array();
    if (($handle = fopen($filename, 'r')) !== FALSE)
    {
        while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
        {
            if(!$header)
                $header = $row;
            else
                $data[] = array_combine($header, $row);
        }
        fclose($handle);
    }
    return $data;
}
$categorydata= csv_to_array('dbinit/category.csv',','); 

foreach ($categorydata as $_data) {

   $category =R::dispense( 'category');
    $category->import($_data);
	R::store($category);
} 
echo 'category import sucessfully';